package com.bwie.bargain.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.bargain.entity.BargainDownEntity;
import com.bwie.bargain.service.BargainDownService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author lfw
 * @email sunlightcs@gmail.com
 * @date 2022-03-09 20:54:42
 */
@RestController
@RequestMapping("bargain/bargaindown")
public class BargainDownController {
    @Autowired
    private BargainDownService bargainDownService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bargainDownService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		BargainDownEntity bargainDown = bargainDownService.getById(id);
        return R.ok().put("bargainDown", bargainDown);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BargainDownEntity bargainDown){
		bargainDownService.save(bargainDown);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BargainDownEntity bargainDown){
		bargainDownService.updateById(bargainDown);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		bargainDownService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
